package com.chunmeng.controller;
import com.chunmeng.pojo.ProfilePojo;
import com.chunmeng.service.ProfileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import java.util.Date;
import java.util.List;
/**
 * @author yd
 * @version 1.0
 * @date 2020/3/5 0005 黄啟军
 */
@Controller
public class ProfileController {
    @Autowired
    ProfileService profileService;
    /**注册功能*/
    @RequestMapping("/register")
    public String register(String account,
                           String password,
                           String email,
                           String phone){
        ProfilePojo profilePojo = new ProfilePojo(account, password, email, phone,new Date());
        profileService.register(profilePojo);
        return "succeed";
    }
    /**登录功能*/
    @RequestMapping("/login")
   public String login(String account,String password){
        ProfilePojo login = profileService.login(account,password);
        if(login.getAccount().equals(account)&&login.getPassword().equals(password)){
            return "succeed";
        }else{
            return "wrong";
        }
    }
    /**根据id查询所有*/
    @RequestMapping("/testAll")
    public String test(){
        List<ProfilePojo> list = profileService.list(1);
        for (ProfilePojo pojo : list) {
            System.out.println(pojo);
        }
        return "succeed";
    }
}
